package com.casper.euler.utils;

import java.util.ArrayList;

public class FibonnaciSeries {
	
	private static FibonnaciSeries fibonnaciSeries;

	private FibonnaciSeries(){
		
	}
	
	public static FibonnaciSeries getInstance(){
		if(fibonnaciSeries==null){
			fibonnaciSeries=new FibonnaciSeries();
		}
		return fibonnaciSeries;
		
	}
	
	public ArrayList<Integer> getSeries(Long mRange){
		ArrayList<Integer> mSeries = new ArrayList<Integer>();
		mSeries.add(0,1);
		mSeries.add(1,2);
		for (int i=2;i<=Integer.MAX_VALUE;i++){
			int value = mSeries.get(i-1)+mSeries.get(i-2);
			if(value<=mRange){
			mSeries.add(i,value);
			}else{
				break;
			}
		}
		return mSeries;
		
	}

}
